package com.huawei;

import java.util.*;

public class HJ019 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        LinkedHashMap<String, Integer> map = new LinkedHashMap<>();
        while(scanner.hasNextLine()){
            String input = scanner.nextLine();
            if(input.length() == 0){
                break;
            }
            dealString(input,map);
        }
        Set<Map.Entry<String, Integer>> entries = map.entrySet();
        int size = entries.size();

        int count = 0;
        for (Map.Entry<String, Integer> e : entries) {
            if(size>8){
                if(count < size-8){
                    count++;
                    continue;
                }
                String key = e.getKey();
                Integer value = e.getValue();
                System.out.println(key+" "+value);
            }else{
                String key = e.getKey();
                Integer value = e.getValue();
                System.out.println(key+" "+value);
            }

        }
    }


    public static void dealString(String input,LinkedHashMap<String, Integer> map){
        String[] split = input.split("\\\\");
        String lastStr = split[split.length - 1];
        String[] lastStrSplit = lastStr.split(" ");
        String basePath = lastStrSplit[0];
        if(basePath.length()>16){
            basePath =  basePath.substring(basePath.length()-16);
        }
        String path = basePath+" "+lastStrSplit[1];
        map.put(path, map.getOrDefault(path,0)+1);
    }

}
